package com.jj.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
public class DemoController {

    @RequestMapping("/demo")
    public String demo(HttpServletResponse response) throws InterruptedException {
        response.addHeader("Access-Control-Allow-Origin", "http://127.0.0.1:5500");
        response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
        response.addHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
        Thread.sleep(10000);
        return "demo";
    }

    @RequestMapping("/getInfo")
    public String getInfo(String name,int age){
        return "server2:getInfo:"+"name:"+name+",age:"+age;
    }
}
